/**
 * 应用中使用的接口定义
 */
import qs from 'qs'
import request from '@/utils/request'
import {TENCENT_MAP_KEY} from "@/config";

/**
 * 登录
 * @returns {*}
 * @param data
 */
export const memberAuth = (data) => request({
  url: '/member/authByCode',
  method: 'POST',
  // data
  header: {
    'content-type': 'application/x-www-form-urlencoded'
  },
  data: qs.stringify(data)
});

export const memberAuthStep2 = (data) => request({
  url: '/member/auth',
  method: 'POST',
  data
});
/**
 * 查询卡片
 * @param id
 * @returns {*}
 */
export const getCard = (id = '') => request({
  url: `/card/${id}`
});

/**
 * 查询卡片
 * @param id
 * @returns {*}
 */
export const getCardByMemberId = id => request({
  url: `/card/getByMemberId/?memberId=${id}`
});

/**
 * 查询卡片
 * @param id
 * @returns {*}
 */
export const getProduct = itemNumbers => request({
  url: `/product/get?itemNumbers=${itemNumbers}`
});

export const postLog = (data) => request({
  url: '/log',
  method: 'POST',
  data
});

export const getLog = prarms => request({
  url: `/log?${qs.stringify(prarms)}`
});

export const getProductQRCode = prarms => request({
  url: `/product/qrcode?${qs.stringify(prarms)}`
});

export const getGeoCoder = address => request({
  url: 'https://apis.map.qq.com/ws/geocoder/v1/',
  data: {
    address,
    key: TENCENT_MAP_KEY
  }
})
export const getRecommendProduct = id => request({
  url: `/product/recommend?unionId=${id}`
});

// 更新隐私 // /api/member/updateprivacy/{id}
export const getUpdatePrivacy = id => request({
  url: `/member/updateprivacy/${id}`,
  data: {}
});

// 保存unionId /api/member/updateunionid
export const getUpdateunionid = (data) => request({
  url: `/member/updateunionid`,
  data
});

//  GET GET /api/member/checkprivacy/{id}  检查隐私 1=>已经更新，0=>没有更新{id} getMemberToken
export const getCheckPrivacy = (id) => request({
  url: `/member/checkprivacy/${id}`,
  data: {}
});
